import java.util.Scanner;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: AliceMana
 * Date: 2022-11-28
 * Time: 15:18
 */
public class Main {
    // 合法括号序列判断
    public static boolean chkParenthesis(String A, int n) {
        // write code here
        Stack<Character> stack1 = new Stack<>();
        for (int i = 0; i < n; i++) {
            if (A.charAt(i) == '(') {
                stack1.push(A.charAt(i));
            } else if (A.charAt(i) == ')') {
                if (stack1.empty()) {
                    return false;
                }
                stack1.pop();
            } else {
                return false;
            }
        }
        return stack1.empty();
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.nextLine();
        System.out.println(chkParenthesis(s, 12));

    }

    // Fibonacci数列
    public static void main1(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int a = 0;
        int b = 1;
        int c;
        while (true) {
            c = a + b;
            // 此时 n 就在 b 和 c 之间
            if (c >= n) {
                break;
            }
            a = b;
            b = c;
        }
        // 求 n 到 b 与 c 之间哪个更近
        int ret = Math.min(n - b, c - n);
        System.out.println(ret);
    }
}
